<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;

class ShippingTemplates extends Model
{
    use HasFactory;
    use PimpableTrait;
    use SoftDeletes;
    /**
     * 计费方式
     */
    public $typeEnum = [
      'type_one' => '按件数',
      'type_two' => '按重量',
      'type_three' => '按体积',
    ];

    /**
     * 可批量赋值的字段
     */
    public $fillable = [
      'name',
      'type',
      'appoint',
      'sort'
    ];

    /**
     * 可搜索的字段
     */
    public $searchable = [
        'name',
        'type',
    ];

    protected $defaultSortCriteria = ['id,desc'];

    public function free(){
        return $this->hasMany(ShippingTemplatesFree::class,'temp_id','id');
    }

    public function region(){
        return $this->hasMany(ShippingTemplatesRegion::class,'temp_id','id');
    }

}
